﻿using System.Buffers;
using eLoop;
using eNets.IO.Buf;

namespace eNets.CBK.Pipe;

sealed partial class StandardPipe<T> : APipe<T>, IPipe<T>
{
    public StandardPipe(MemoryPool<T> memoryPool, ITaskScheduler scheduler) 
        : base(scheduler)
    {
        this.Reader = new StandardPipeReader(this);
        this.Writer = new StandardPipeWriter(this);
        this.buffer = BufferProvider.CreateSafeBuffer<T>(memoryPool);
    }

    private IBuffer<T> buffer;

    public override long ReadableLength
    {
        get { return this.buffer.ReadableLength; }
    }
    public override IPipeReader<T> Reader { get; }
    public override IPipeWriter<T> Writer { get; }
}